import { Component, OnInit, ViewChild, ViewContainerRef, ComponentRef, ComponentFactoryResolver, EventEmitter } from '@angular/core';
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
import { EntryListComponent } from '../../content/entry-list/entry-list.component';
import { FlowInfoComponent } from '../../modal/flow-info/flow-info.component';
import { EntryHistoryComponent } from '../../modal/entry-history/entry-history.component';
import { NewChangeInfoComponent } from '../../modal/new-change-info/new-change-info.component';
import { ContrastInfoComponent } from '../../modal/contrast-info/contrast-info.component';
import { EntryChangeComponent } from '../../modal/entry-change/entry-change.component';
import { HistoryChangeComponent } from '../../modal/history-change/history-change.component';
import { RouteDetailComponent } from '../../content/route-detail/route-detail.component';
import { BatchModeComponent } from '../../content/batch-mode/batch-mode.component';
import { ReadingNotesComponent } from '../../modal/reading-notes/reading-notes.component';
import { ModifyPageService } from './modify-page.service';
import { AppPaginationComponent, PaginationModel } from "../../../../../widgets/pagination/pagination.component";
import { environment } from "../../../../../../environments/environment";
import * as _ from "lodash";
import { Util } from '../../../../../common/util';
import { DataService } from 'app/services/data.service';
import { ViewSearchComponent } from '../../modal/view-search/view-search.component';
import { TablePageComponent } from '../../table/table-page/table-page.component';

@Component({
  selector: 'app-modify-page',
  templateUrl: './modify-page.component.html',
  styleUrls: ['./modify-page.component.scss'],
  providers: [ModifyPageService]
})
export class ModifyPageComponent implements OnInit {

  // 条目查看列表
  @ViewChild("modityTablePage", { read: ViewContainerRef })
  modityTablePage: ViewContainerRef;
  tablePageComponent: ComponentRef<TablePageComponent>;
  @ViewChild("entryList2", { read: ViewContainerRef })
  entryList2: ViewContainerRef;
  entryListComponent2: ComponentRef<EntryListComponent>;
  // 阅读维护须知正文
  @ViewChild("readNote", { read: ViewContainerRef })
  readNote: ViewContainerRef;
  readingNotesComponent: ComponentRef<ReadingNotesComponent>;
  //流程查看列表
  @ViewChild("modifyFlowInfo", { read: ViewContainerRef })
  modifyFlowInfo: ViewContainerRef;
  flowInfoComponent: ComponentRef<FlowInfoComponent>;
  //在途明细
  @ViewChild("routeDetail", { read: ViewContainerRef })
  routeDetail: ViewContainerRef;
  routeDetailComponent: ComponentRef<RouteDetailComponent>;
  //查看条目历史列表
  @ViewChild("entryHistory", { read: ViewContainerRef })
  entryHistory: ViewContainerRef;
  entryHistoryComponent: ComponentRef<EntryHistoryComponent>;
  //查看最近15天变更数据
  @ViewChild("newChangeInfo", { read: ViewContainerRef })
  newChangeInfo: ViewContainerRef;
  newChangeInfoComponent: ComponentRef<NewChangeInfoComponent>;
  //查看最新条目对比数据
  @ViewChild("contrastInfo", { read: ViewContainerRef })
  contrastInfo: ViewContainerRef;
  contrastInfoComponent: ComponentRef<ContrastInfoComponent>;
  //条目修改
  @ViewChild("entryChange", { read: ViewContainerRef })
  entryChange: ViewContainerRef;
  entryChangeComponent: ComponentRef<EntryChangeComponent>;
  // 查询历史变更记录
  @ViewChild("historyChange", { read: ViewContainerRef })
  historyChange: ViewContainerRef;
  historyChangeComponent: ComponentRef<HistoryChangeComponent>;
  // 在途批次
  @ViewChild("routeBatch", { read: ViewContainerRef })
  routeBatch: ViewContainerRef;
  batchModeComponent: ComponentRef<BatchModeComponent>;
  //搜索
  @ViewChild("nQDIIModifySearch", { read: ViewContainerRef })
  nQDIIModifySearch: ViewContainerRef;
  viewSearchComponent: ComponentRef<ViewSearchComponent>;
  // lodash
  public _: any = _;
  public cloneList:any = [];
  // 菜单数据
  public menuData: any;
  // 菜单权限set
  public menuResourceSet: any = [];

  public listData: any = [];
  //适用基金组列表
  public groupList: any = [];
  public tabType: any;
  //分页配置
  public listPageInfo = {
    currentPageNum: 1,
    pageSize: 50,
    totalPages: 1,
    total: 0,
    pagesShow: 5,
    startRow: 0,
    endRow: 0,
    pageList: [5, 10, 25, 50, 100]
  };
  //列表全选
  public isCheckedAll: any = false;

  //查询列表getBody
  public getBody: any = {
    pageIndex: 1,
    pageSize: 50,
    sItemType: '',//属性
    sFileSource: '',//条款出处
    sFileName: '',//文件名称
    sFundGroupds: '',//适用基金类别
    f1: '',//内容
    sFundType: '',//适用基金组
    sAccountName: '',//账户名称
    sValid: "", // sValid 是否有效
    nNdId: ''// nNdId 风控条目编号
  };
  public searchBody: any = {};
  public sFundType: any = [];
  public sFundGroupds: any = [];
  public sFileSourcelist: any = [];
  //字典值列表
  public dictionaryList: any = {
    NX_SOURCE: [],//条款出处
    RISK_ACCOUNT_TYPE: []//适用基金组类别
  }

  // tab权限列表
  public tabRight: any = [];
  // 公司制度-条款出处权限控制
  public sFileSource: any;

  public sFileSourceData: any;
  constructor(
    public resolver: ComponentFactoryResolver,
    public modifyService: ModifyPageService,
    public dataService: DataService,
  ) { }

  ngOnInit() {
    let that = this;
    // 警告！以下函数调用顺序不可随意调整，会导致下拉框数据加载不出来！！！
    this.loadGSZD();
    // 多选下拉框
    window['$'](".select2").select2();
    // 字典值
    this.dictionaryList = JSON.parse(localStorage.getItem("dictionaryList"));
    this.tabControl();
    this.fundGroupList();
    Util.loadSelect(this.dictionaryList.RISK_ACCOUNT_TYPE, 'NqdiiModifyFundType')







    // // 字典值
    // this.dictionaryList = JSON.parse(localStorage.getItem("dictionaryList"));
    // // 多选下拉框
    // window['$'](".select2").select2();
    // this.loadlist();
    // this.fundGroupList();
    // Util.loadSelect(this.dictionaryList.RISK_ACCOUNT_TYPE, 'NqdiiModifyFundType')
    // Util.loadSelect(this.dictionaryList.NX_SOURCE, 'NqdiiModifyFileSource')
    // //初始化适用基金组多选框,因为使用的不是字典值，所以通用方法无法使用
    // setTimeout(()=>{
    //   this.fundGroupsSelect2();
    // },500)

    // 权限处理
    this.dataService.initTree.subscribe((data) => {
      if (data) {
        // let SessionMenuData = sessionStorage.getItem('menu');
        // this.menuData = JSON.parse(SessionMenuData)
        // this.menuResourceSet = [];
        // _.forEach(this.menuData, (item, index) => {
        //   if (item.sName == '风控管理') {
        //     _.forEach(item.children, (it, idx) => {
        //       if (it.sName == '非QDII条目管理') {
        //         _.forEach(it.children, (ite, i) => {
        //           if (ite.sName == '条目修改') {
        //             that.menuResourceSet = ite.resourceSet
        //             sessionStorage.setItem('btn-NQDII', this.menuResourceSet);
        //           }
        //         })
        //       }
        //     })
        //   }
        // })
        this.menuResourceSet = [];
        this.menuResourceSet = Util.getAuthority('风控管理', '非QDII条目管理', '条目修改');
        sessionStorage.setItem('btn-NQDII', this.menuResourceSet);
      }
    })
    this.menuResourceSet = [];
    this.menuResourceSet = Util.getAuthority('风控管理', '非QDII条目管理', '条目修改');
    sessionStorage.setItem('btn-NQDII', this.menuResourceSet);
    // console.info(this.menuResourceSet)

    this.dataService.nQDIIsEntryChangeEmitter = new EventEmitter();
    this.dataService.nQDIIsEntryChangeEmitter.subscribe((value: any) => {
      if (value) {
        switch (value) {
          case 'entryChangeSave':
            window['$']('#modal5').modal('hide');
            that.loadlist();
            break;
          case 'refreshModifyList':
            window['$']('#modal5').modal('hide');
            that.loadlist();
            break;
        }
      }
    })

    //重新定义发射事件，避免多次接收
    this.dataService.nQDIIViewEmitter = new EventEmitter();
    this.dataService.nQDIIViewEmitter.subscribe((value: any) => {
      if (value) {
        // this.searchBody = _.cloneDeep(this.dataService.nQDIIViewSearchInfo);
        // this.searchlist();
        this.getBody = _.cloneDeep(this.dataService.nQDIIViewSearchInfo);
        this.sFundType = _.cloneDeep(this.dataService.nQDIIViewSearchInfo.sFundType.split(','));
        this.sFundGroupds = _.cloneDeep(this.dataService.nQDIIViewSearchInfo.sFundGroupds.split(','));
        this.sFileSourcelist = _.cloneDeep(this.dataService.nQDIIViewSearchInfo.sFileSource.split(','));
        window['$']('#NqdiiModifyFundType').selectpicker('val', that.sFundType);
        window['$']('#NqdiiModifyFundGroupds').selectpicker('val', that.sFundGroupds);
        window['$']('#NqdiiModifyFileSource').selectpicker('val', that.sFileSourcelist);
        // console.log(this.sFundType)
        // console.log(this.sFundGroupds)
        // console.log(this.sFileSourcelist)
        this.loadlist();
        window['$']('#nQDIIModifySearch').modal('hide');
      }
    })
  }
  //初始化适用基金组多选框
  fundGroupsSelect2() {
    let that = this;
    var html = '';
    for (var i = 0; i < this.groupList.length; i++) {
      html += "<option value='" + this.groupList[i].nFgId + "'>" + this.groupList[i].sFgName + "</option>";
    }
    window['$']("#NqdiiModifyFundGroupds").html(html);
    window['$']('#NqdiiModifyFundGroupds').selectpicker({
      size: "8",
      actionsBox: "true",
      title: "请选择",
      selectAllText: "全选",
      deselectAllText: "取消全选",
      width: 182
    });
  }
  // 条目查看列表
  showTablePage(item) {
    // 判断组件是否已创建，如果创建先注销
    if (this.tablePageComponent && this.tablePageComponent.instance) {
      this.tablePageComponent.destroy();
    }

    // 动态创建组件的实例
    const tablePageComponent = this.resolver.resolveComponentFactory(TablePageComponent);
    this.tablePageComponent = this.modityTablePage.createComponent(tablePageComponent);
    this.tablePageComponent.instance.listData = item;
    this.tablePageComponent.instance.listType = '2';
    this.tablePageComponent.instance.setColor = this.cloneList;
  }
  showEntryList2(item) {
    // 判断组件是否已创建，如果创建先注销
    if (this.entryListComponent2 && this.entryListComponent2.instance) {
      this.entryListComponent2.destroy();
    }

    // 动态创建组件的实例
    const entryListComponent2 = this.resolver.resolveComponentFactory(EntryListComponent);
    this.entryListComponent2 = this.entryList2.createComponent(entryListComponent2);
    this.entryListComponent2.instance.tabType = item;
  }
  // 流程查看列表
  showFlowInfo() {
    let count: any = this.entryCount();
    if (count.length == 1) {
      if (this.flowInfoComponent && this.flowInfoComponent.instance) {
        this.flowInfoComponent.destroy();
      }

      // 动态创建组件的实例
      const flowInfoComponent = this.resolver.resolveComponentFactory(FlowInfoComponent);
      this.flowInfoComponent = this.modifyFlowInfo.createComponent(flowInfoComponent);
      this.flowInfoComponent.instance.item = count[0];
      this.flowInfoComponent.instance.itemType = 'nNdId';
      window['$']('#modal1').modal('show');
    } else {
      window['swal']("提示", "请选择一条数据", "warning")
    }

  }
  //判断选中的条目数量
  entryCount() {
    let entryList: any = [];
    _.forEach(this.listData, item => {
      if (item.isChecked) {
        // delete item.isChecked;
        entryList.push(item);
      }
    })
    return entryList;
  }
  // 条目历史列表
  showEntryHistory() {
    let count: any = this.entryCount();
    if (count.length == 1) {
      // 判断组件是否已创建，如果创建先注销
      if (this.entryHistoryComponent && this.entryHistoryComponent.instance) {
        this.entryHistoryComponent.destroy();
      }
      // 动态创建组件的实例
      const entryHistoryComponent = this.resolver.resolveComponentFactory(EntryHistoryComponent);
      this.entryHistoryComponent = this.entryHistory.createComponent(entryHistoryComponent);
      this.entryHistoryComponent.instance.nNjId = count[0].nNdId;
      window['$']('#modal2').modal('show');
    } else {
      window['swal']("提示", "请选择一条数据", "warning")
    }
  }
  // 查看最近15天变更数据
  showNewChangeInfo() {
    // 判断组件是否已创建，如果创建先注销
    if (this.newChangeInfoComponent && this.newChangeInfoComponent.instance) {
      this.newChangeInfoComponent.destroy();
    }
    // 动态创建组件的实例
    const newChangeInfoComponent = this.resolver.resolveComponentFactory(NewChangeInfoComponent);
    this.newChangeInfoComponent = this.newChangeInfo.createComponent(newChangeInfoComponent);
  }
  // 查看最新条目对比数据
  showContrastInfo() {
    // 判断组件是否已创建，如果创建先注销
    if (this.contrastInfoComponent && this.contrastInfoComponent.instance) {
      this.contrastInfoComponent.destroy();
    }
    // 动态创建组件的实例
    const contrastInfoComponent = this.resolver.resolveComponentFactory(ContrastInfoComponent);
    this.contrastInfoComponent = this.contrastInfo.createComponent(contrastInfoComponent);
  }
  // 条目修改
  showEntryChange() {
    let count: any = this.entryCount();
    let unOnPassageList: any = [];
    let unOnPassageItem: any;
    if (count.length != 0) {
      // 判断组件是否已创建，如果创建先注销
      if (this.entryChangeComponent && this.entryChangeComponent.instance) {
        this.entryChangeComponent.destroy();
      }

      _.forEach(count, item => {
        delete item.isChecked;
        if (item.sState != '正常') {
          unOnPassageList.push(item.nNdId)
        }
      })
      unOnPassageItem = unOnPassageList.join(',')
      // 动态创建组件的实例
      if (unOnPassageList.length > 0) {
        window['swal']("提示", "仅能修改正常状态的数据", "warning")
      } else {
        const entryChangeComponent = this.resolver.resolveComponentFactory(EntryChangeComponent);
        this.entryChangeComponent = this.entryChange.createComponent(entryChangeComponent);
        this.entryChangeComponent.instance.list = count;
        console.log(count);
        window['$']('#modal5').modal('show');
      }
    } else {
      window['swal']("提示", "请选择数据", "warning")
    }
  }
  // 查询历史变更记录modal
  showHistoryChange() {
    // 判断组件是否已创建，如果创建先注销
    if (this.historyChangeComponent && this.historyChangeComponent.instance) {
      this.historyChangeComponent.destroy();
    }
    let nNdIdList: any = [];
    let nNdIds: any;
    _.forEach(this.listData, item => {
      if (item.isChecked) {
        nNdIdList.push(item.nNdId);
      }
    })
    nNdIds = nNdIdList.join(',')
    // 动态创建组件的实例
    const historyChangeComponent = this.resolver.resolveComponentFactory(HistoryChangeComponent);
    this.historyChangeComponent = this.historyChange.createComponent(historyChangeComponent);
    this.historyChangeComponent.instance.getBody.nNdIds = nNdIds;
    window['$']('#historyChange').modal('show');

  }
  // 在途明细
  showRouteDetail() {
    // 判断组件是否已创建，如果创建先注销
    if (this.routeDetailComponent && this.routeDetailComponent.instance) {
      this.routeDetailComponent.destroy();
    }
    // 动态创建组件的实例
    const routeDetailComponent = this.resolver.resolveComponentFactory(RouteDetailComponent);
    this.routeDetailComponent = this.routeDetail.createComponent(routeDetailComponent);
  }
  // 在途批次
  showBatchMode() {
    // 判断组件是否已创建，如果创建先注销
    if (this.batchModeComponent && this.batchModeComponent.instance) {
      this.batchModeComponent.destroy();
    }
    // 动态创建组件的实例
    const batchModeComponent = this.resolver.resolveComponentFactory(BatchModeComponent);
    this.batchModeComponent = this.routeBatch.createComponent(batchModeComponent);
    this.batchModeComponent.instance.menuResource = this.menuResourceSet;
  }
  // 显示阅读维护须知modal
  showReadingNote() {
    // 判断组件是否已创建，如果创建先注销
    if (this.readingNotesComponent && this.readingNotesComponent.instance) {
      this.readingNotesComponent.destroy();
    }
    // 动态创建组件的实例
    const readingNotesComponent = this.resolver.resolveComponentFactory(ReadingNotesComponent);
    this.readingNotesComponent = this.readNote.createComponent(readingNotesComponent);
  }
  // 条数分页
  sizeChange(pageSize: number) {
    if (pageSize !== this.listPageInfo.pageSize) {
      this.listPageInfo.pageSize = pageSize;
      this.loadlist();
    }
  }
  // 列表分页
  pageNavigation(currentPageNum: number) {
    this.listPageInfo.currentPageNum = currentPageNum;
    this.loadlist(this.listPageInfo.currentPageNum, this.listPageInfo.pageSize);
  }
  // 列表全选
  checkedAll() {
    if (this.isCheckedAll) {
      // 更新为全选
      _.forEach(this.listData, item => {
        item.isChecked = true;
      });
    } else {
      // 更新为不全选
      _.forEach(this.listData, item => {
        item.isChecked = false;
      });
    }
  }
  // 列表是否全选
  ctrlCheckAll() {
    let that = this;
    let checkList = [];
    _.forEach(this.listData, item => {
      if (item.isChecked == true) {
        checkList.push(item);
      }
    })
    if (checkList.length == this.listData.length) {
      this.isCheckedAll = true;
    } else {
      this.isCheckedAll = false;
    }
  }
  //分页列表
  loadlist(pageNum?, pageSize?) {
    this.getBody.sFundType = this.sFundType.join(',');
    this.getBody.sFundGroupds = this.sFundGroupds.join(',');
    this.getBody.sFileSource = this.sFileSourcelist.join(',');
    this.getBody.pageIndex = pageNum ? pageNum : this.listPageInfo.currentPageNum;
    this.getBody.pageSize = pageSize ? pageSize : this.listPageInfo.pageSize;
    console.log(this.getBody)
    this.modifyService.list(this.getBody).subscribe(data => {
      if (data) {
        this.listData = data.list;
        console.log(data);
        this.cloneList = _.cloneDeep(data.list)
        this.showTablePage(this.listData);
        this.listPageInfo.currentPageNum = data.pageNum;
        this.listPageInfo.totalPages = data.pages;
        this.listPageInfo.total = data.total;
        this.listPageInfo.startRow = data.startRow;
        this.listPageInfo.endRow = data.endRow;
      }
    })
  }
  //搜索查询分页列表
  searchlist(pageNum?, pageSize?) {
    this.getBody.pageIndex = pageNum ? pageNum : this.listPageInfo.currentPageNum;
    this.getBody.pageSize = pageSize ? pageSize : this.listPageInfo.pageSize;
    this.modifyService.list(this.searchBody).subscribe(data => {
      if (data) {
        this.listData = data.list;
        console.log(data);
        this.listPageInfo.currentPageNum = data.pageNum;
        this.listPageInfo.totalPages = data.pages;
        this.listPageInfo.total = data.total;
        this.listPageInfo.startRow = data.startRow;
        this.listPageInfo.endRow = data.endRow;
        // window['$']('#NqdiiViewFileSource').selectpicker('render');
        // window['$']('#NqdiiViewFileSource').selectpicker('refresh');
      }
    })

  }
  //显示模态框
  showModal(item) {
    let that = this;
    switch (item) {
      //查看流程信息modal
      case '1':
        this.showFlowInfo();
        break;
      //查看条目历史modal
      case '2':
        this.showEntryHistory();

        break;
      //查看最近15天变更数据modal
      case '3':
        this.showNewChangeInfo();
        window['$']('#modal3').modal('show');
        break;
      //查看最新对比数据modal
      case '4':
        this.showContrastInfo();
        window['$']('#modal4').modal('show');
        break;
      //条目修改modal
      case '5':
        this.showEntryChange();
        break;
      //阅读须知正文modal
      case 'readNote':
        this.showReadingNote();
        window['$']('#readNote').modal('show');
        break;
      case 'historyChange':
        this.showHistoryChange();
        break;
    }
  }
  //获取基金组信息列表
  fundGroupList() {
    let that = this;
    let getBody = {
      sType: 0
    }
    this.modifyService.fundGroupList(getBody).subscribe(data => {
      if (data) {
        this.groupList = data;
        //初始化适用基金组多选框,因为使用的不是字典值，所以通用方法无法使用
        setTimeout(() => {
          this.fundGroupsSelect2();
        }, 300)
      }
    })
  }
  exportExcel() {
    let that = this;
    // console.log("===============");
    // let checkedItem = [];
    // _.forEach(this.listData, item => {
    //   if (item.isChecked) {
    //     checkedItem.push(item.nQdId);
    //   }
    // })
    // nQdIdList=checkedItem;
    // let converItem: any = checkedItem.join(',');
    let getBody = {
      sItemType: this.getBody.sItemType,//属性
      sFileSource: this.getBody.sFileSource,//条款出处
      sFileName: this.getBody.sFileName,//文件名称
      sFundGroupds: this.getBody.sFundGroupds,//适用基金类别
      f1: this.getBody.f1,//内容
      sFundType: this.getBody.sFundType,//适用基金组
      sAccountName: this.getBody.sAccountName,//账户名称
      dOprDateConditon: this.getBody.dOprDateConditon//时间点
    }
    const iframe = window['$']("<iframe id='downloadiframe'>");
    iframe.attr('style', 'display:none');
    //  转码，兼容ie
    iframe.attr('src', environment.server + '/pms/v1/riskmanage/data/export/pmsNqdiiDataList?token=' + sessionStorage.getItem('token')
      + '&sItemType=' + getBody.sItemType + '&sFileSource=' + getBody.sFileSource
      + '&sFileName=' + getBody.sFileName + '&sFundGroupds=' + getBody.sFundGroupds
      + '&f1=' + getBody.f1 + '&sFundType=' + getBody.sFundType
      + '&sAccountName=' + getBody.sAccountName + '&dOprDateConditon=' + getBody.dOprDateConditon);
    window['$']('body').append(iframe);
    setTimeout("$('#downloadiframe').remove()", 60000);
  }
  //点击切换tab时调用查询接口
  changeTab(sItemType, flag) {
    this.getBody.sItemType = sItemType;
    this.loadlist(1);
    // if (flag == 1) {
    //   // NqdiiViewFileSource
    //   window['$']('#NqdiiModifyFileSource').selectpicker('destroy');
    //   console.log(this.sFileSourceData);
    //   Util.loadSelect(this.sFileSourceData, 'NqdiiModifyFileSource');
    // } else if (flag == 0) {
    //   window['$']('#NqdiiModifyFileSource').selectpicker('destroy');
    //   Util.loadSelect(this.dictionaryList.NX_SOURCE, 'NqdiiModifyFileSource')
    // }
  }

  // tab权限控制
  tabControl() {
    this.modifyService.tabControl().subscribe((data) => {
      if (data) {
        this.tabRight = data;
        console.log(this.tabRight);
        this.getBody.sItemType = this.tabRight[0];
        console.log(this.tabRight[0])
        this.loadlist(1);
       
        if (this.tabRight[0] !== 'gszd') {
          // window['$']('#NqdiiViewFileSource').selectpicker('destroy');
          setTimeout(() => {
            Util.loadSelect(this.dictionaryList.NX_SOURCE, 'NqdiiModifyFileSource')
          }, 1)
        } else {
          // window['$']('#NqdiiViewFileSource').selectpicker('destroy');
          setTimeout(() => {
            Util.loadSelect(this.sFileSourceData, 'NqdiiModifyFileSource');
          }, 1)

        }
      }

    })
  }
  // 公司制度-条款出处权限控制
  loadGSZD() {
    this.modifyService.loadGSZD().subscribe((data) => {
      if (data) {
        this.sFileSourceData = data;
      }
    })

  }
  //风控条目编号正整数控制
  integerControl() {
    setTimeout(() => {
      this.getBody.nNdId = this.getBody.nNdId.replace(/[^0-9]/g, '');
    });
  }
  //搜索
  shownQDIIModifySearch() {
    // 判断组件是否已创建，如果创建先注销
    if (this.viewSearchComponent && this.viewSearchComponent.instance) {
      this.viewSearchComponent.destroy();
    }
    // 动态创建组件的实例
    const viewSearchComponent = this.resolver.resolveComponentFactory(ViewSearchComponent);
    this.viewSearchComponent = this.nQDIIModifySearch.createComponent(viewSearchComponent);
    this.viewSearchComponent.instance.getBody.sItemType = _.cloneDeep(this.getBody.sItemType);
    window['$']('#nQDIIModifySearch').modal('show');
  }

  // 点击表格头排序
  orderData(colName) {
    let listDataAsc = _.orderBy(this.listData, [colName], ["asc"]);
    if (JSON.stringify(this.listData) == JSON.stringify(listDataAsc)) {
      listDataAsc = _.orderBy(this.listData, [colName], ["desc"]);
    }
    this.listData = listDataAsc;
  }

}
